import React from 'react'

function StateHook() {
    const [num, setNum] = React.useState(0);
    const [time, setTime] = React.useState(new Date().getTime())
    const changeNums = () => {
        setNum(num => num + 1)
    }
    const getTimes = () => {
        setTime(() => (new Date().getTime()))
    }
    return (
        <div className="container" style={{padding:'40px',backgroundColor:'green',marginBottom:'20px'}}>
			<h4 className='display-4'>当前数值为{num}</h4>
			<button onClick={changeNums} className="btn btn-danger mr-3">加一</button>
			<h4 className='display-4'>当前时间为{time}</h4>
			<button onClick={getTimes} className="btn btn-primary">获取时间</button>
		</div>
    )
}

export default StateHook